package edu.towson.cosc603.coffeemaker;

import junit.framework.TestCase;

import org.junit.Before;
import org.junit.Test;

/**
 * Test case for the Inventory class.
 * 
 * @author Odessa
 */
public class InventoryTest extends TestCase
{
	Inventory inventory;



	/**
	 * Sets up the fixture for the test.
	 * 
	 * @throws java.lang.Exception
	 */
	@Before
	public void setUp() throws Exception
	{
		inventory = new Inventory();
	}



	/**
	 * Test method for
	 * {@link edu.towson.cosc603.coffeemaker.Inventory#getChocolate()}.
	 */
	@Test
	public void testGetChocolate()
	{
		assertEquals(15, inventory.getChocolate());
	}



	/**
	 * Test method for
	 * {@link edu.towson.cosc603.coffeemaker.Inventory#setChocolate(int)}. Tests
	 * the setChocolate method when the number entered is greater than zero.
	 */
	@Test
	public void testSetChocolate_GreaterThanZero()
	{
		inventory.setChocolate(5);
		assertEquals(5, inventory.getChocolate());
	}



	/**
	 * Test method for
	 * {@link edu.towson.cosc603.coffeemaker.Inventory#setChocolate(int)}. Tests
	 * the setChocolate method when the number entered is less than zero.
	 */
	@Test
	public void testSetChocolate_LessThanZero()
	{
		inventory.setChocolate(-5);
		assertEquals(0, inventory.getChocolate());
	}



	/**
	 * Test method for
	 * {@link edu.towson.cosc603.coffeemaker.Inventory#getCoffee()}.
	 */
	@Test
	public void testGetCoffee()
	{
		assertEquals(15, inventory.getCoffee());
	}



	/**
	 * Test method for
	 * {@link edu.towson.cosc603.coffeemaker.Inventory#setCoffee(int)}. Tests
	 * the setCoffee method when the number entered is greater than zero.
	 */
	@Test
	public void testSetCoffee_GreaterThanZero()
	{
		inventory.setCoffee(5);
		assertEquals(5, inventory.getCoffee());
	}



	/**
	 * Test method for
	 * {@link edu.towson.cosc603.coffeemaker.Inventory#setCoffee(int)}. Tests
	 * the setCoffee method when the number entered is less than zero.
	 */
	@Test
	public void testSetCoffee_LessThanZero()
	{
		inventory.setCoffee(-5);
		assertEquals(0, inventory.getCoffee());
	}



	/**
	 * Test method for
	 * {@link edu.towson.cosc603.coffeemaker.Inventory#getMilk()}.
	 */
	@Test
	public void testGetMilk()
	{
		assertEquals(15, inventory.getMilk());
	}



	/**
	 * Test method for
	 * {@link edu.towson.cosc603.coffeemaker.Inventory#setMilk(int)}. Tests the
	 * setMilk method when the number entered is greater than zero.
	 */
	@Test
	public void testSetMilk_GreaterThanZero()
	{
		inventory.setMilk(5);
		assertEquals(5, inventory.getMilk());
	}



	/**
	 * Test method for
	 * {@link edu.towson.cosc603.coffeemaker.Inventory#setMilk(int)}. Tests the
	 * setMilk method when the number entered is less than zero.
	 */
	@Test
	public void testSetMilk_LessThanZero()
	{
		inventory.setMilk(-5);
		assertEquals(0, inventory.getMilk());
	}



	/**
	 * Test method for
	 * {@link edu.towson.cosc603.coffeemaker.Inventory#getSugar()}.
	 */
	@Test
	public void testGetSugar()
	{
		assertEquals(15, inventory.getSugar());
	}



	/**
	 * Test method for
	 * {@link edu.towson.cosc603.coffeemaker.Inventory#setSugar(int)}. Tests the
	 * setMilk method when the number entered is greater than zero.
	 */
	@Test
	public void testSetSugar_GreaterThanZero()
	{
		inventory.setSugar(5);
		assertEquals(5, inventory.getSugar());
	}



	/**
	 * Test method for
	 * {@link edu.towson.cosc603.coffeemaker.Inventory#setSugar(int)}. Tests the
	 * setMilk method when the number entered is less than zero.
	 */
	@Test
	public void testSetSugar_LessThanZero()
	{
		inventory.setSugar(-5);
		assertEquals(0, inventory.getSugar());
	}



	/**
	 * Test method for
	 * {@link edu.towson.cosc603.coffeemaker.Inventory#enoughIngredients(edu.towson.cosc603.coffeemaker.Recipe)}
	 * . Tests the enoughIngredients method when there is enough in the
	 * inventory.
	 */
	@Test
	public void testEnoughIngredients_True()
	{
		Recipe r1 = new Recipe();
		r1.setName("Coffee");
		r1.setPrice(50);
		r1.setAmtCoffee(6);
		r1.setAmtMilk(1);
		r1.setAmtSugar(1);
		r1.setAmtChocolate(0);

		assertTrue(inventory.enoughIngredients(r1));
	}



	/**
	 * Test method for
	 * {@link edu.towson.cosc603.coffeemaker.Inventory#enoughIngredients(edu.towson.cosc603.coffeemaker.Recipe)}
	 * . Tests the enoughIngredients method when there isn't enough in the
	 * inventory.
	 */
	@Test
	public void testEnoughIngredients_False()
	{
		Recipe r1 = new Recipe();
		r1.setName("Coffee");
		r1.setPrice(50);
		r1.setAmtCoffee(6);
		r1.setAmtMilk(1);
		r1.setAmtSugar(1);
		r1.setAmtChocolate(0);

		inventory.setChocolate(0);
		inventory.setCoffee(0);
		inventory.setMilk(0);
		inventory.setSugar(0);

		assertFalse(inventory.enoughIngredients(r1));
	}



	/**
	 * Test method for
	 * {@link edu.towson.cosc603.coffeemaker.Inventory#toString()}.
	 */
	@Test
	public void testToString()
	{
		String result = "Coffee: 15" + "\n" + "Milk: 15" + "\n" + "Sugar: 15"
				+ "\n" + "Chocolate: 15" + "\n";

		assertEquals(result, inventory.toString());
	}

}
